package com.itheima.mapper;

import com.itheima.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BrandMapper {
    /**
     * 添加
     * @param brand
     */
    @Select("insert into tb_brand values  (null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from tb_brand where id=#{id}")
    void delectById(String id);

    /**
     * 修改
     * @param brand
     */
    @Update("UPDATE tb_brand SET `brand_name` = #{brandName}, `company_name` = #{companyName}, `ordered` = #{ordered}, `description` = #{description}, `status` = #{status} WHERE `id` = #{id}")
    void update(Brand brand);

    /**
     * 通过id查找
     * @param id
     * @return
     */
    @Select("select * from tb_brand where id =#{id}")
    Brand findById(String id);

    /**
     * 查找全部
     * @return
     */
    @Select("select * from tb_brand")
    List<Brand> findAll();
}
